package com.shop.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.dao.OrderDetailDao;
import com.shop.entity.OrderDetail;
import com.shop.service.OrderDetailService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * description: 该文件说明
 *
 * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
 * @version 1.0
 * @date 2018/10/15 14:30
 **/
@Service
public class OrderDetailServiceImp implements OrderDetailService {
    @Resource
    private OrderDetailDao orderDetailDao;
    /**
     * description:<分页订单详情>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/15 14:31
     * @param  
     * @return 
     **/
    @Override
    public PageInfo<OrderDetail> findOrderDetailList(Integer page,Integer rows,OrderDetail orderDetail) {
        PageHelper.startPage(page,rows);
        List<OrderDetail> list = null;
        try {
            list = orderDetailDao.findOrderDetail(orderDetail);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new PageInfo<OrderDetail>(list);
    }

    /**
     * description:<通过订单id查找订单详情>
     *
     * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
     * @date   2018/10/15 15:41
     * @param  
     * @return 
     **/
    @Override
    public List<OrderDetail> findOrderDetailByOrderId(String orderId) {
        if(StringUtils.isEmpty(orderId)){
            return null;
        }
        List<OrderDetail> list = orderDetailDao.findOrderDetailByOrderId(orderId);
        return list;
    }
}
